/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author rodrigo
 */
@Entity
@Table(name = "Prova")
@NamedQueries({
    @NamedQuery(name = "Prova.findAll", query = "SELECT p FROM Prova p"),
    @NamedQuery(name = "Prova.findByProvaId", query = "SELECT p FROM Prova p WHERE p.provaId = :provaId"),
    @NamedQuery(name = "Prova.findByTitulo", query = "SELECT p FROM Prova p WHERE p.titulo = :titulo"),
    @NamedQuery(name = "Prova.findByDescricao", query = "SELECT p FROM Prova p WHERE p.descricao = :descricao"),
    @NamedQuery(name = "Prova.findByTempolimite", query = "SELECT p FROM Prova p WHERE p.tempolimite = :tempolimite"),
    @NamedQuery(name = "Prova.findByDisponivelapartide", query = "SELECT p FROM Prova p WHERE p.disponivelapartide = :disponivelapartide"),
    @NamedQuery(name = "Prova.findByDisponivellate", query = "SELECT p FROM Prova p WHERE p.disponivellate = :disponivellate"),
    @NamedQuery(name = "Prova.findByQtdQuestoes", query = "SELECT p FROM Prova p WHERE p.qtdQuestoes = :qtdQuestoes"),
    @NamedQuery(name = "Prova.findByNotamaxima", query = "SELECT p FROM Prova p WHERE p.notamaxima = :notamaxima")})
public class Prova implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "prova_id")
    private Integer provaId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "titulo")
    private String titulo;
    @Size(max = 255)
    @Column(name = "descricao")
    private String descricao;
    @Column(name = "tempolimite")
    @Temporal(TemporalType.TIME)
    private Date tempolimite;
    @Column(name = "disponivelapartide")
    @Temporal(TemporalType.DATE)
    private Date disponivelapartide;
    @Column(name = "disponivellate")
    @Temporal(TemporalType.DATE)
    private Date disponivellate;
    @Column(name = "qtd_questoes")
    private Integer qtdQuestoes;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "notamaxima")
    private Float notamaxima;
    @ManyToMany(mappedBy = "provaList")
    private List<Questao> questaoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "provaId")
    private List<Gabarito> gabaritoList;
    @JoinColumn(name = "autor_usuario_id", referencedColumnName = "usuario_id")
    @ManyToOne(optional = false)
    private Usuario autorUsuarioId;

    public Prova() {
    }

    public Prova(Integer provaId) {
        this.provaId = provaId;
    }

    public Prova(Integer provaId, String titulo) {
        this.provaId = provaId;
        this.titulo = titulo;
    }

    public Integer getProvaId() {
        return provaId;
    }

    public void setProvaId(Integer provaId) {
        this.provaId = provaId;
    }

    public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public Date getTempolimite() {
        return tempolimite;
    }

    public void setTempolimite(Date tempolimite) {
        this.tempolimite = tempolimite;
    }

    public Date getDisponivelapartide() {
        return disponivelapartide;
    }

    public void setDisponivelapartide(Date disponivelapartide) {
        this.disponivelapartide = disponivelapartide;
    }

    public Date getDisponivellate() {
        return disponivellate;
    }

    public void setDisponivellate(Date disponivellate) {
        this.disponivellate = disponivellate;
    }

    public Integer getQtdQuestoes() {
        return qtdQuestoes;
    }

    public void setQtdQuestoes(Integer qtdQuestoes) {
        this.qtdQuestoes = qtdQuestoes;
    }

    public Float getNotamaxima() {
        return notamaxima;
    }

    public void setNotamaxima(Float notamaxima) {
        this.notamaxima = notamaxima;
    }

    public List<Questao> getQuestaoList() {
        return questaoList;
    }

    public void setQuestaoList(List<Questao> questaoList) {
        this.questaoList = questaoList;
    }

    public List<Gabarito> getGabaritoList() {
        return gabaritoList;
    }

    public void setGabaritoList(List<Gabarito> gabaritoList) {
        this.gabaritoList = gabaritoList;
    }

    public Usuario getAutorUsuarioId() {
        return autorUsuarioId;
    }

    public void setAutorUsuarioId(Usuario autorUsuarioId) {
        this.autorUsuarioId = autorUsuarioId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (provaId != null ? provaId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Prova)) {
            return false;
        }
        Prova other = (Prova) object;
        if ((this.provaId == null && other.provaId != null) || (this.provaId != null && !this.provaId.equals(other.provaId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.Prova[ provaId=" + provaId + " ]";
    }
    
}
